package com.xqls.service.impl;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;

import com.xqls.dal.model.TScheduleJob;
import com.xqls.service.SokectService;
import com.xqls.util.ContextUtil;
/**
 * @Description: 计划任务执行处 无状态
 * @author Administrator
 *
 */
public class QuartzJobFactory implements Job{
	public final Logger log = Logger.getLogger(this.getClass());
	SokectService sokectService = (SokectService) ContextUtil
			.getBean(SokectService.class);
	QuatzOperationServiceImpl quatzOperationServiceImpl = (QuatzOperationServiceImpl) ContextUtil.getBean(QuatzOperationServiceImpl.class);
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		TScheduleJob scheduleJob = (TScheduleJob) context.getMergedJobDataMap().get("scheduleJob");  
		sokectService.closeValve(scheduleJob.getfJobName());
		try {
			quatzOperationServiceImpl.deleteJob(scheduleJob);
		} catch (SchedulerException e) {
			log.error("删除任务异常", e);
		}
	}

}
